package com.itheima.common;

/**
 * 获取当前登录用户ID
 *
 * @author hua
 * @since 2022/11/2 11:12
 */
public class BaseContext {
//把用户id保存到ThreadLocal中
    //用户id是Long类型
    public static final ThreadLocal<Long> THREAD_LOCAL_CURRENT_User_ID=new ThreadLocal<>();

    /**
     * 设置用户ID
     */
    public static void setCurrentUserId(Long currentUserId){
        //设置值
        THREAD_LOCAL_CURRENT_User_ID.set(currentUserId);
    }

    /**
     *
     * 获取用户ID
     */
    public static  Long getCurrentUserId(){
        return THREAD_LOCAL_CURRENT_User_ID.get();
    }
}
